package org.opens.apache.io;

import org.apache.commons.io.FileUtils;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class ReadFile {

    /**
     * 功能:
     *      使用FileUtil直接读取文件的内容到List中.
     */
    @Test
    public void test1() throws IOException {
        File file = new File("C:\\Users\\张玉明\\Desktop\\test\\read.txt");
        List<String> strings = FileUtils.readLines(file, "UTF-8");
        System.out.println(strings);
    }

    @Test
    public void test2() {
        String resource = this.getClass().getResource("/read.txt").toString();
        System.out.println(resource);
    }

}
